<form [formGroup]='formModel2' (submit)='onSubmit()'>
  <div>
    <input type="date" formControlName='title'> 
    <div [hidden]='!formModel2.hasError("required","title")'>
      必须的
    </div>
  </div>


  <div formGroupName='dateRange'>
    起始日期
    <input type="date" formControlName='startTime'> 结束日期
    <input type="date" formControlName='endTime'>
  </div>

  <!-- 如果嵌套在Group里面的需要写数组的形式  -->
  <div [hidden]='formModel2.get("dateRange").get("startTime").valid || formModel2.get("dateRange").get("startTime").untouched '>
      <div [hidden]='!formModel2.hasError("errorMsg",["dateRange","startTime"])'>
          时间是必须要填的
      </div>
  </div>

  <!-- <div>
    <ul formArrayName='emailArray'>
      <li  *ngFor="let item of formModel.get('emailArray').controls; let i=index;" >
        <input type="text" [formControlName]='i'>
      </li>
    </ul>
  </div>

  <div>
    <button type="button" (click)='add()'>
      增加一个
    </button>
  </div> -->
  <div>
    <!-- 表单状态 -->
    {{formModel2.status}}
  </div>
  <div>
    <button type="submit">
      保存
    </button>
  </div>
</form>

<div>
  不在表单域里
  <input type="date" [formControl]='userName'>
</div>